Skip to content

feat: support Math in Markdown#299

Draft
lumirlumir wants to merge 11 commits intomainfrom
lumirlumir-patch-1
Draft

feat: support Math in Markdown#299
lumirlumir wants to merge 11 commits intomainfrom
lumirlumir-patch-1

Conversation

@lumirlumir
Copy link
Copy Markdown
Member

@lumirlumir lumirlumir commented Jan 27, 2026

Prerequisites checklist

What is the purpose of this pull request?

This PR updates Code Explorer to support the Math parsing option for the Markdown language, introduced in eslint/markdown#617 and released as part of @eslint/markdown v8.

I've also updated e2e-tests/options.test.ts to include tests for the newly added Math option.

What changes did you make? (Give an overview)

  • Before:
image
  • After:
image image

Related Issues

Ref: eslint/markdown#331

Is there anything you'd like reviewers to focus on?

Actually, adding AST node interaction and expansion tests would make this feature more robust, but there are currently no tests for those cases. I’d like to continue the work on #398, since it requires many of the changes.

@eslintbot eslintbot added this to Triage Jan 27, 2026
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jan 27, 2026
@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage Jan 27, 2026
@lumirlumir lumirlumir added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jan 27, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 27, 2026

Deploy Preview for eslint-code-explorer ready!

Name Link
🔨 Latest commit 1c9d590
🔍 Latest deploy log https://app.netlify.com/projects/eslint-code-explorer/deploys/69e627182e99f00008179fd3
😎 Deploy Preview https://deploy-preview-299--eslint-code-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ayatobai
Copy link
Copy Markdown

@lumirlumir, I wanted to share some constructive feedback on your PRs:

  1. I’ve noticed that refactors and fixes/features are sometimes combined in the same PR. Splitting these into separate PRs would make the logic changes easier to review and merge.
  2. Tasks like this one seem to be taking a few hours, where I’d expect something closer to ~30 minutes. I’d suggest utilizing AI tools for the boilerplate and tests to help speed things up.

@lumirlumir lumirlumir requested a review from Copilot April 20, 2026 13:31
@lumirlumir lumirlumir moved this from Implementing to Needs Triage in Triage Apr 20, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support in Code Explorer for the new math parsing option in the Markdown language (introduced in @eslint/markdown v8), including a UI toggle and an e2e test update.

Changes:

  • Add a new markdownMath boolean option (type + default) and expose it in the Markdown options panel.
  • Pass math through to @eslint/markdown’s parser via languageOptions.
  • Bump @eslint/markdown to ^8.0.1 and extend the e2e options-panel test to assert the new switch is visible.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/lib/const.ts Adds markdownMath to the default Markdown options.
src/hooks/use-explorer.ts Extends MarkdownOptions to include markdownMath.
src/hooks/use-ast.ts Wires markdownMath into the markdown parser languageOptions.
src/components/options.tsx Adds a new “Math” switch to the Markdown options UI.
package.json Updates @eslint/markdown dependency to v8.
package-lock.json Lockfile updates for @eslint/markdown@8 and its transitive deps/engines.
e2e-tests/options.test.ts Adds an assertion that the “Math” switch is visible for Markdown.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<LabeledSwitch
id="markdownMath"
label="Math"
checked={markdownMath}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked={markdownMath} assumes the value is always a boolean, but if a user has older persisted state (before markdownMath existed) it can be undefined and cause controlled/uncontrolled issues. Either ensure rehydration/migration fills markdownMath, or defensively coalesce here (e.g. default to false).

Suggested change
checked={markdownMath}
checked={markdownMath ?? false}

Copilot uses AI. Check for mistakes.
Comment thread src/hooks/use-ast.ts
markdownFrontmatter === "off"
? false
: markdownFrontmatter,
math: markdownMath,
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If markdownMath is missing from rehydrated persisted state, math: markdownMath can be undefined. Consider defaulting this to false here (and/or adding a persist migration) so the parser option is always a boolean.

Suggested change
math: markdownMath,
math: markdownMath ?? false,

Copilot uses AI. Check for mistakes.
Comment thread package.json
Comment thread src/hooks/use-explorer.ts
markdownFrontmatter: MarkdownFrontmatter;
markdownMath: boolean;
};

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a new field to MarkdownOptions can break existing persisted state: zustand persist merges state shallowly, so older markdownOptions objects will overwrite defaultMarkdownOptions and may omit markdownMath, yielding undefined at runtime. Consider adding a persist version + migrate/custom merge, or patching rehydrated markdownOptions to include markdownMath: false when missing.

Suggested change
type PersistedMarkdownOptions = Omit<MarkdownOptions, "markdownMath"> & {
markdownMath?: boolean;
};
export const normalizeMarkdownOptions = (
markdownOptions?: PersistedMarkdownOptions,
): MarkdownOptions => ({
...defaultMarkdownOptions,
...markdownOptions,
markdownMath: markdownOptions?.markdownMath ?? false,
});

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll dig into this problem a bit more in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted There is consensus among the team that this change meets the criteria for inclusion feature

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

4 participants